import ora from 'ora'
import chalk from 'chalk'
import { execSync } from 'child_process'

async function install() {
    const spinner = ora({
        text: chalk.blue('Installing dependencies...\n'),
        color: 'cyan',
        spinner: {
            frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
        }
    }).start()

    try {
        execSync('pnpm install', { stdio: 'inherit' })
        spinner.succeed(chalk.green('Dependencies installed successfully! 📦'))

        // 显示一些友好的提示
        console.log('\n' + chalk.cyan('🚀 Ready to start:'))
        console.log(chalk.yellow('\n  pnpm dev') + chalk.gray('    - Start development server'))
        console.log(chalk.yellow('  pnpm build') + chalk.gray('  - Build for production'))
        console.log(chalk.yellow('  pnpm test') + chalk.gray('   - Run tests\n'))

    } catch (error) {
        spinner.fail(chalk.red('Failed to install dependencies 😢'))
        console.error(error)
        process.exit(1)
    }
}

install() 